#include <iostream>
#include <vector>
#include <set>
using namespace std;

class Solution {
public:
    int longestConsecutive(vector<int>& nums) {
        if (nums.size() == 0 || nums.size() == 1) {
            return nums.size();
        }

        set<int> s;
        for (auto e : nums) {
            s.insert(e);
        }

        vector<int> arr;
        for (auto e : s) {
            arr.push_back(e);
        }

        int goal = 1;
        int cur = 1;
        for (int i = 0, j = 0; j < arr.size(); ++j) {
            if (i != j && arr[j] == arr[i] + j - i) {
                cur += 1;
            }
            else {
                goal = max(goal, cur);
                cur = 1;
                i = j;
            }
        }

        return max(goal, cur);
    }
};

int main()
{
    vector<int> nums = { 100,4,200,1,3,2 };
    Solution().longestConsecutive(nums);

    return 0;
}